﻿@model NewsEditModel
@{
    ViewData["Title"] = Model.NewsId == 0
        ? "Add news"
        : $"Edit news {Model.NewsId}";
}

<h2 class="mt-2">@ViewData["Title"]</h2>
<link rel="stylesheet" href="/lib/editor-md/css/editormd.css" />
<script src="/lib/editor-md/editormd.js"></script>

<form method="post" class="setting-form-group">
    <input type="hidden" asp-for="NewsId" />

    <div class="form-group">
        <label class="font-weight-bold" asp-for="Title"></label>
        <input class="form-control" asp-for="Title" />
    </div>

    <div class="form-group">
        <label class="font-weight-bold">Activity</label>
        <div class="custom-control custom-checkbox">
            <input type="checkbox" class="custom-control-input" asp-for="Active" id="isactive">
            <label class="custom-control-label" for="isactive">Is Active and Visible to Public</label>
        </div>
    </div>

    <div class="form-group">
        <label class="font-weight-bold">Content</label>
        <div style="height:640px"><div id="editormd"><textarea style="display:none;" asp-for="MarkdownSource"></textarea></div></div>
    </div>

    <script type="text/javascript">
        $(function () {
            var editor = editormd({
                id: "editormd",
                path: "/lib/editor-md/lib/",
                tex: true,
                imageUpload: true,
                imageFormats: ["jpg", "jpeg", "gif", "png", "svg"],
                imageUploadURL: "/api/static/images-upload?type=n",
            });
            editormd.katexURL = {
                js: "/lib/katex/katex.min",
                css: "/lib/katex/katex.min"
            };
        });
    </script>

    <div class="form-group mt-3">
        <button type="submit" class="btn btn-primary">Save</button>
    </div>
</form>
